package com.aps.system.service.impl;

import com.aps.system.domain.vo.FztzMoneyVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aps.system.mapper.VexpContractFztzMapper;
import com.aps.system.domain.VexpContractFztz;
import com.aps.system.service.IVexpContractFztzService;

import javax.annotation.Resource;

/**
 * 服装鞋部合同台账Service业务层处理
 *
 * @author 陈炎兴
 * @date 2024-07-15
 */
@Service
public class VexpContractFztzServiceImpl extends ServiceImpl<VexpContractFztzMapper, VexpContractFztz> implements IVexpContractFztzService {
    @Resource
    private VexpContractFztzMapper vexpContractFztzMapper;

    public List<VexpContractFztz> vexpContractFztzList;

    /**
     * 查询服装鞋部合同台账
     *
     * @param Price 服装鞋部合同台账主键
     * @return 服装鞋部合同台账
     */
    @Override
    public VexpContractFztz selectVexpContractFztzByPrice(BigDecimal Price) {
        return vexpContractFztzMapper.selectVexpContractFztzByPrice(Price);
    }

    /**
     * 查询服装鞋部合同台账列表
     *
     * @param vexpContractFztz 服装鞋部合同台账
     * @return 服装鞋部合同台账
     */
    @Override
    public List<VexpContractFztz> selectVexpContractFztzList(VexpContractFztz vexpContractFztz) {
        List<VexpContractFztz> list = vexpContractFztzMapper.selectVexpContractFztzList(vexpContractFztz);
        vexpContractFztzList = list;
        return list;
    }

    /**
     * 新增服装鞋部合同台账
     *
     * @param vexpContractFztz 服装鞋部合同台账
     * @return 结果
     */
    @Override
    public int insertVexpContractFztz(VexpContractFztz vexpContractFztz) {
        return vexpContractFztzMapper.insertVexpContractFztz(vexpContractFztz);
    }

    /**
     * 修改服装鞋部合同台账
     *
     * @param vexpContractFztz 服装鞋部合同台账
     * @return 结果
     */
    @Override
    public int updateVexpContractFztz(VexpContractFztz vexpContractFztz) {
        return vexpContractFztzMapper.updateVexpContractFztz(vexpContractFztz);
    }

    /**
     * 批量删除服装鞋部合同台账
     *
     * @param Prices 需要删除的服装鞋部合同台账主键
     * @return 结果
     */
    @Override
    public int deleteVexpContractFztzByPrices(BigDecimal[] Prices) {
        return vexpContractFztzMapper.deleteVexpContractFztzByPrices(Prices);
    }

    /**
     * 删除服装鞋部合同台账信息
     *
     * @param Price 服装鞋部合同台账主键
     * @return 结果
     */
    @Override
    public int deleteVexpContractFztzByPrice(BigDecimal Price) {
        return vexpContractFztzMapper.deleteVexpContractFztzByPrice(Price);
    }

    @Override
    public FztzMoneyVo getMoney() {
        List<VexpContractFztz> list = vexpContractFztzList;
        FztzMoneyVo fztzMoneyVo = new FztzMoneyVo();
        double piMoney = 0.0;
        double paymentMoney = 0.0;
        double tradeReceivable = 0.0;
        double actualPaymentReceived = 0.0;
        double factoryContract = 0.0;
        double actualPrepaid = 0.0;
        for (VexpContractFztz vexpContractFztz : list) {
            piMoney = piMoney + vexpContractFztz.getGoodsAmount().doubleValue();
            paymentMoney = paymentMoney + vexpContractFztz.getDJAmount().doubleValue();
            tradeReceivable = tradeReceivable + vexpContractFztz.getSAccountMoney().doubleValue();
            actualPaymentReceived = actualPaymentReceived + vexpContractFztz.getTotalReceivedMoney().doubleValue();
            factoryContract = factoryContract + vexpContractFztz.getPurAmount().doubleValue();
            actualPrepaid =  actualPrepaid + vexpContractFztz.getyAmount().doubleValue();
        }
        fztzMoneyVo.setPiMoney(piMoney);
        fztzMoneyVo.setPaymentMoney(paymentMoney);
        fztzMoneyVo.setTradeReceivable(tradeReceivable);
        fztzMoneyVo.setActualPaymentReceived(actualPaymentReceived);
        fztzMoneyVo.setFactoryContract(factoryContract);
        fztzMoneyVo.setActualPrepaid(actualPrepaid);
        return fztzMoneyVo;
    }
}
